<template>
    <div>
        <button @click="doUpload">生成测试数据并上传</button>
    </div>
</template>

<script setup>
import Mock from 'mockjs';
import dayjs from 'dayjs'
import axios from 'axios';

const doMock = () => {
  const data = []


  // for (item of type) {
    for(let year = 2020; year < 2024 ; year++){
      for(let month = 1 ; month < 13 ; month++){
    for (let hour = 0; hour < 24; hour++) {
      let item;
      if (hour < 7) {
        item = Mock.mock({
          "时间": dayjs(new Date(year, month, 11, hour, 0, 0)).format('YYYY-MM-DD HH:mm:ss'),
          "门诊人次|100-2000": 1,
          "检查人次|900-1200": 1,
          "住院人次|10-123": 1,
          "出院人次|712-134": 1,
          "日间手术次数|20-100":1,
          "门诊人次费用|12-32": 1,
          "住院人次费用|312-4345": 1,
          "药品人次费用|36-74": 1,
          // "车流量|10-20": 1,
        })
      } else if (hour < 12) {
        item = Mock.mock({
          "时间": dayjs(new Date(year, month, 11, hour, 0, 0)).format('YYYY-MM-DD HH:mm:ss'),
          "门诊人次|100-20123": 1,
          "检查人次|912-1320": 1,
          "住院人次|121-1310": 1,
          "出院人次|600-1121": 1,
          "日间手术次数|20-800":1,
          "门诊人次费用|123-325": 1,
          "住院人次费用|312-3345": 1,
          "药品人次费用|313-643": 1,
          // "车流量|10-20": 1,
        })
      } else if (hour < 15) {
        item = Mock.mock({
          "时间": dayjs(new Date(year, month, 11, hour, 0, 0)).format('YYYY-MM-DD HH:mm:ss'),
          "门诊人次|1-2000": 1,
          "检查人次|9-1200": 1,
          "住院人次|1-121231": 1,
          "出院人次|7-132141": 1,
          "日间手术次数|20-10220":1,
          "门诊人次费用|12-3225": 1,
          "住院人次费用|31-43435": 1,
          "药品人次费用|36-743": 1,
          // "车流量|10-20": 1,

        })
      } else if (hour < 20) {
        item = Mock.mock({
          "时间": dayjs(new Date(year, month, 11, hour, 0, 0)).format('YYYY-MM-DD HH:mm:ss'),
          "门诊人次|10-200020": 1,
          "检查人次|90-120023": 1,
          "住院人次|1-12341": 1,
          "出院人次|7-1341": 1,
          "日间手术次数|2-1000":1,
          "门诊人次费用|1-325": 1,
          "住院人次费用|2-4345": 1,
          "药品人次费用|3-743": 1,
          // "车流量|10-20": 1,
        })
      } else {
        item = Mock.mock({
          "时间": dayjs(new Date(year, month, 11, hour, 0, 0)).format('YYYY-MM-DD HH:mm:ss'),
          "门诊人次|1-2000": 1,
          "检查人次|9-1200": 1,
          "住院人次|10-1241": 1,
          "出院人次|7-1341": 1,
          "日间手术次数|2-100":1,
          "门诊人次费用|1-325": 1,
          "住院人次费用|3-434": 1,
          "药品人次费用|3-743": 1,
          // "车流量|10-20": 1,

        })
      }
      data.push(item)
    }
  }
  } 
  
  
  // }
  
  return data
}

const doUpload = () => {
  const data = doMock()
  axios.post('/api/hdfs/upload-by-json', { 
    data, 
    name: "default",
    header: ['时间', ...window.CONFIG.dataHeader]
  }).then(res => {
    console.log(res)
  })
}

</script>

<style lang="scss" scoped>

</style>